<?php

namespace Util;
/**
 * 公共常量
 */
class Common
{
//    const MAIN_HOST = 'http://my.power.cn';//主域名
    const MAIN_HOST = 'https://www.chdyzw.com';//主域名
    const CASH_TOKEN = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgFANehnEfLNc3e6LUynqyNm6dNWpBDynqf1QN';
    const SLICK_IMAGE = 'SLICK_IMAGE';//轮播图1
    const CONTRACT_CLASS_ALL = 'CONTRACT_CLASS_ALL';// 合同类全部1
    const SET_WEB_NORMAL_WEN = 'SET_WEB_NORMAL_WEN';// 设置web普通问1
    const SET_WEB_CLASS_TOP = 'SET_WEB_CLASS_TOP';// 排行榜
    const SET_WEB_TOP_DATA = 'SET_WEB_TOP_DATA';// 设置web顶部数据
    const REDIS_INDEX_CLASS = 'REDIS_INDEX_CLASS';// redis索引大类
    const REDIS_WAP_CONTRACT_LIST = 'REDIS_WAP_CONTRACT_LIST';// 手机主页列表key
    const REDIS_WEB_CONTRACT_LIST = 'REDIS_WEB_CONTRACT_LIST';// pc主页列表key
    const SET_CONTENT_DOCX = 'set_content_docx';//通配符seo文档标题
    const SHT_MEMBER_CODE = 'SHT_MEMBER_CODE_';//注册手机号验证码reis前缀
    const BIND_MEMBER_CODE = 'BIND_MEMBER_CODE_';//绑定手机号验证码reis前缀
    const MEMBER_STATUS_OK = 'enable';//正常
    const MEMBER_STATUS_ERROR = 'disable';//禁用
    const MEMBER_LOGIN_MOBILE = 2;//1=微信  2=手机
    const MEMBER_LOGIN_WECHAT = 1;//1=微信
    const DEL_SHOW = 1;// 显示
    const DEL_HIDE = 0;// 删除
    const YES = 1;
    const NO = 0;
    const MEMBER_REDIS_INFO = 'MEMBER_REDIS_INFO';//登陆态缓存的key
    const USER_REDIS_INFO = 'USER_REDIS_INFO';//crm管理登录缓存的key
    const DISTRIBUTOR_REDIS_INFO = 'DISTRIBUTOR_REDIS_INFO';//管理登录缓存的key
    const MEMBER_VIP = 1;  // 1=会员  0= 非会员
    const MEMBER_COLLECT = 'MEMBER_COLLECT_';//用户收藏列表的key
    const HOME_HISTORY = 'HOME_HISTORY_';//用户浏览历史
    const IS_FINISH = 1;//生成完图片的文档
    const NOT_FINISH = 0;//未生成完图片的文档

    const REDIS_POINT_KEYWORD = 'REDIS_POINT_KEYWORD';//获取redis的key
    const REDIS_MAIN_BANNER ='REDIS_MAIN_BANNER';//获取首页外链图
    const REDIS_WAP_BANNER ='REDIS_WAP_BANNER';//获取手机端外链图

    const ORDER_NOT_PAY = 0;//订单状态未支付
    const ORDER_PAY = 1;//订单状态已支付

    const ORDER_WX_PAY = 1;//微信支付
    const ORDER_ALI_PAY = 2;//支付宝支付
    const ORDER_RANK_LIST='ORDER_RANK_LIST';//生成订单排行榜

    const CONTRACT_PNG = 'CONTRACT_PNG';//首页数据缓存;
    const CHILDREN_ALL_CLASS = 'CHILDREN_ALL_CLASS';//获取子类所有类内容key

    const DOWN_HISTORY_SPECIAL =2;//专题下载历史
    const DOWN_HISTORY_CONTRACT = 1; //合同下载历史
    /**
     * 搜索
     */
    const SEARCH_RANK_LIST = 'SEARCH_RANK_LIST';//搜索词排行榜
    /**构造where查询
     * @param array $params
     * @return array
     */
    public static function buildWhere(array $params):array{
        $where = [];
        foreach ($params as $key => $value){
            $where[] = [$key, $value];
        }
        return $where;
    }

    /**utc时间转换为prc时间
     * @param string $date
     * @return string
     * @throws \Exception
     */
    public static function utcToPrc(string $date):string{

        $utcDateTime = new \DateTime($date, new \DateTimeZone('UTC'));
        $prcTimeZone = new \DateTimeZone('Asia/Shanghai');
        $utcDateTime->setTimezone($prcTimeZone);
        $prcTimeString = $utcDateTime->format('Y-m-d H:i:s');
        return $prcTimeString;
    }
}
